<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"			
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

	<!-- 
		Explain:
		
		* Values are transmitted to the server as strings but normally stored in model as typed attributes (e.g. java.util.Date).
		* It's exactly the duty of a Converter to transform the values between these to states.
		* There are two standard converter (tags):
		** f:convertDateTime
		** f:convertNumber
		* Other standard converters are automatically used when appropriate (see long example)
		
		* Validators check the user input (before appying them to the model)
		* Standard validators are available (including one for Regex)
		* Alternative: Bean Validation:
		** Pro: Define rules on the business object once instead of defining them in the view
		
		* Custom converters and validator may be developed.
		
		*
	 -->
	 

	<h:body> 
	
		<h:messages />
	
		<h:form>
		
			<h:panelGrid columns="3">
				<h:outputLabel value="Date:" for="date" />
				<h:inputText id="date" label="Date" value="#{valuesBean.dateValue}" 
					required="true"> <!-- This is important. Otherwise no validation is executed when sending an empty value -->
					<f:convertDateTime pattern="dd.MM.yyyy" />
					<f:validateRequired />
				</h:inputText>
				<h:message for="date" />
				
				<h:panelGroup />
				<h:outputText value="#{valuesBean.dateValue}">
					<f:convertDateTime pattern="dd.MM.yyyy" />
				</h:outputText>
				<h:panelGroup />
				
				<h:outputLabel value="Long:" for="long" />
				<h:inputText id="long" label="long" value="#{valuesBean.longValue}">
					<f:validateLongRange minimum="5" />
				</h:inputText>
				<h:message for="long" />
				
				<h:panelGroup />
				<h:outputText value="#{valuesBean.longValue}" />
				<h:panelGroup />
				
				<h:panelGroup />
				<h:commandButton value="Submit" />
			</h:panelGrid>
		
		</h:form>
	
	</h:body>

</html>